export default {
    namespaced: true,
    state() {
        return {
            // 管理的用户对象信息
            userId: "",
            username: "",
            avatar: "",
            token: "",
        }
    },
    mutations: {
        // 同步state中用户的信息
        toggleUser(state, serverUserData) {
            state.userId = serverUserData.adminUser.id;
            state.username = serverUserData.adminUser.username;
            state.avatar = serverUserData.avatar;
        },

        // 清除状态
        clearUser(state) {
            state.userId = "";
            state.avatar = "";
            state.token = "";
        }
    },
    actions: {
        // async toLogout()
        // async toLogin()
    },
    getters: {

        // 获取用户ID
        getUserId(state) {
            return state.userId;
        },
        // 判断是否登录
        isLogin(state) {
            return state.userId != "";
        }
    }
}